//
//  HomeHeaderView.m
//  HeWeiZhiNeng
//
//  Created by 林建 on 2017/12/12.
//  Copyright © 2017年 YanCeyMichael.github.io. All rights reserved.
//

#import "HomeHeaderView.h"

@implementation HomeHeaderView

-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = Color.theme;
        self.nowDegreeLabel.textAlignment = NSTextAlignmentLeft;
        self.degreeLabel.textAlignment = NSTextAlignmentLeft;
        self.cityLabel.textAlignment = NSTextAlignmentRight;
        self.washIndexLabel.textAlignment = NSTextAlignmentRight;
        self.nowDegreeLabel.text = @"14°";
        self.degreeLabel.text = @"晴18~24℃";
        self.cityLabel.text = @"常州";
        self.washIndexLabel.text = @"洗车指数：非常适宜";
        self.weatherView.image = [UIImage imageNamed:@"sy_surname"];
    }
    return self;
}

#pragma mark ----- 更多 -----
-(UIImageView *)moreView{
    if (!_moreView) {
        _moreView = [[UIImageView alloc]init];
        _moreView.image = [UIImage imageNamed:@"sy_gengduo"];
        [self addSubview:_moreView];
    }
    return _moreView;
}

#pragma mark ----- 天气 -----
-(UILabel *)degreeLabel{
    if (!_degreeLabel) {
        _degreeLabel = [[UILabel alloc]init];
        [self addSubview:_degreeLabel];
        [self CreatNewLabel:_degreeLabel color:Color.fullBtnTitle font:Common_Font(12)];
    }
    return _degreeLabel;
}

#pragma mark ----- 天气情况 -----
-(UIImageView *)weatherView{
    if (!_weatherView) {
        _weatherView = [[UIImageView alloc]init];
        [self addSubview:_weatherView];
    }
    return _weatherView;
}

#pragma mark ----- 温度 -----
-(UILabel *)nowDegreeLabel{
    if (!_nowDegreeLabel) {
        _nowDegreeLabel = [[UILabel alloc]init];
        [self addSubview:_nowDegreeLabel];
        [self CreatNewLabel:_nowDegreeLabel color:Color.fullBtnTitle font:Common_Font(24)];
    }
    return _nowDegreeLabel;
}

#pragma mark ----- 城市 -----
-(UILabel *)cityLabel{
    if (!_cityLabel) {
        _cityLabel = [[UILabel alloc]init];
        [self addSubview:_cityLabel];
        [self CreatNewLabel:_cityLabel color:Color.fullBtnTitle font:Common_Font(12)];
    }
    return _cityLabel;
}

#pragma mark ----- 洗车指数 -----
-(UILabel *)washIndexLabel{
    if (!_washIndexLabel) {
        _washIndexLabel = [[UILabel alloc]init];
        [self addSubview:_washIndexLabel];
        [self CreatNewLabel:_washIndexLabel color:Color.fullBtnTitle font:Common_Font(12)];
    }
    return _washIndexLabel;
}

-(void)CreatNewLabel:(UILabel *)label color:(UIColor *)color font :(UIFont *)font{
    label.userInteractionEnabled = YES;
    label.textColor = color;
    label.font = font;
}

-(void)layoutSubviews{
    [self.moreView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.mas_top).offset(20);
        make.left.mas_equalTo(self.mas_left).offset(15);
        make.size.mas_equalTo(CGSizeMake(20, 16));
    }];
    [self.degreeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self.mas_leading).offset(71);
        make.width.mas_equalTo(150);
        make.bottom.mas_equalTo(self.mas_bottom).offset(-16-55);
        make.height.mas_equalTo(15);
    }];
    [self.nowDegreeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self.mas_leading).offset(71);
        make.width.mas_equalTo([[SingleManager shareManager] getTextWidth:self.nowDegreeLabel.text withHeight:24 font:Common_Font(24)]+5);
        make.bottom.mas_equalTo(self.degreeLabel.mas_top).offset(-8);
        make.height.mas_equalTo(25);
    }];
    [self.weatherView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.nowDegreeLabel.mas_centerY);
        make.left.mas_equalTo(self.nowDegreeLabel.mas_right);
        make.size.mas_equalTo(CGSizeMake(22, 22));
    }];
    [self.washIndexLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.trailing.mas_equalTo(self.mas_trailing).offset(-15);
        make.width.mas_equalTo(150);
        make.bottom.mas_equalTo(self.mas_bottom).offset(-16-55);
        make.height.mas_equalTo(15);
    }];
    [self.cityLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.trailing.mas_equalTo(self.mas_trailing).offset(-15);
        make.width.mas_equalTo(60);
        make.bottom.mas_equalTo(self.washIndexLabel.mas_top).offset(-11);
        make.height.mas_equalTo(15);
    }];
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
